<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/17
 * Time: 16:08
 */

namespace app\api\job;

use app\common\model\LotteryGame;
use think\Db;
use think\queue\Job;

class HeroPk
{
    protected $maxTime = 6;

    public function fire(Job $job,$data)
    {
        sleep(60);
        $sequencenum = $data['sequencenum'];
        $arr = explode('-',$sequencenum);
        if( isset($arr[1]) && $arr[1] ){
            $lotteryGame = LotteryGame::where('id',$arr[1])->where('status','0')->find();
            if( !$lotteryGame ){
                $job->delete();
                return;
            }
            LotteryGame::where('id',$arr[1])->update([
                'status'    => 3,
                'end_time'  => time()
            ]);
            $job->delete();
            return;
        }
        $job->delete();
    }
}